package org.apache.flink.runtime.consumermanager.slots;

import java.util.concurrent.CompletableFuture;

import org.apache.flink.api.common.time.Time;
import org.apache.flink.runtime.allocatedeploy.execution.CommandDescriptor;
import org.apache.flink.runtime.allocatedeploy.execution.ExecutionID;
import org.apache.flink.runtime.clusterframework.types.AllocationID;
import org.apache.flink.runtime.messages.Acknowledge;
import org.apache.flink.runtime.resourceconsumer.ConsumingMasterId;
import org.apache.flink.runtime.rpc.RpcTimeout;

/**
 * @类名: ConsumerManagerGateway
 * @说明: 消费者管理网关
 *
 * @author   leehom
 * @Date	 2023年11月3日 下午10:17:30
 * 修改记录：
 *
 * @see 	 
 */
/** Consumer manager gateway interface to communicate with the consumer manager. */
public interface ProviderManagerGateway {

    /**
     * Return the address of the task manager with which the gateway is associated.
     *
     * @return Address of the task manager with which this gateway is associated.
     */
    String getAddress();
    
    /**
     * @说明：下发命令
     *
     * @author leehom
     * @param command
     * @param args
     * @param timeout
     * @return
     * 
     */
    CompletableFuture<Acknowledge> submitCommand(CommandDescriptor commandDescriptor, 
    			ConsumingMasterId consumingMasterId, Time timeout);
    
    CompletableFuture<Acknowledge> cancelCommand(ExecutionID executionID, Time timeout);

    /**
     * Frees the slot with the given allocation ID.
     *
     * @param allocationId identifying the slot to free
     * @param cause of the freeing operation
     * @param timeout for the operation
     * @return Future acknowledge which is returned once the slot has been freed
     */
    CompletableFuture<Acknowledge> freeSlot(
            final AllocationID allocationId, final Throwable cause, @RpcTimeout final Time timeout);

}
